<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>add-资产录入</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js"></script>
	<script type="text/javascript" src="../frame/assets/js/lib/jquery.min.js"></script>
	<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
	<script src="../frame/layui/lay/modules/layer.js"></script>
    <link rel="stylesheet" href="../frame/layui/lay/modules/layer/default/layer.css">
    <link rel="stylesheet" href="../frame/layui/css/layui.css"  media="all">
    <link rel="stylesheet" href="../frame/assets/css/lib/bootstrap.min.css">
    <link rel="stylesheet" href="../frame/assets/css/lib/font-awesome.min.css">
    <link rel="stylesheet" href="../frame/assets/css/lib/themify-icons.css">
    <link rel="stylesheet" href="../frame/assets/css/lib/unix.css">
    <link rel="stylesheet" href="../frame/assets/css/style.css">
    <link rel="stylesheet" href="../frame/assets/css/lib/menubar/sidebar.css">
    <link rel="stylesheet" href="../frame/assets/css/lib/sweetalert/sweetalert.css">
    <style>
    .dd{
    	color:#ff0000;
    	padding-left:30px;
    	front-size:12px;
    }
    </style>
</head>

<body style="margin-left:25%;height: 1200px;">
<!--内容-->
<div class="content-wrap" >
    <div class="main">
        <div class="container-fluid">
            <!--欢迎栏-->
            <div class="row">
                <div class="col-lg-8 p-r-0 title-margin-right">
                    <div class="page-header">
                        <div class="page-title">
                            <h1>资产录入</h1>
                             
                        </div>
                    </div>
                </div>
            </div>
            
              <h4><i class="layui-icon layui-icon-face-smile" style="font-size: 30px; color: #1E9FFF;"></i>  添加资产</h4><br><br>
              <div class="layui-text" style="font-size:18px">

				<label>资产编码&nbsp;：</label>
				<input type="text" name="zcid" id="zcid" onblur="check2()">
				<div class="dd" id="p2"></div>
				  <label>例如&nbsp;：zc01(zc+序号）</label>
				<br><br>
				<label>资产名称&nbsp;：</label>
				<input type="text" name="zcname" id="zcname" onblur="check3()">
				<div class="dd" id="p3"></div>
				<label>例如&nbsp;：空调</label>
				<br><br>
				<label>资产金额&nbsp;：</label>
				<input type="text" name="money" id="money" onblur="check4()">
				<div class="dd" id="p4">
				</div>
				<label>例如&nbsp;：3200(p+序号)</label>
				<br><br>
				  <div class="layui-form-item">
					  <label>资产大类&nbsp;:&nbsp;&nbsp;</label>
						  <select style="width: 230px;height:35px " name="zcclass" id="zcclass" lay-filter="aihao">
							  <option value=""></option>
							  <option value="运输类">运输类</option>
							  <option value="办公类" selected="">办公类</option>
							  <option value="影视类">影视类</option>
							  <option value="工具类">工具类</option>
							  <option value="医疗类">医疗类</option>
							  <option value="家电类">家电类</option>
							  <option value="其他类">其他类</option>
						  </select>
				  </div>
				<label>例如&nbsp;：家电类(产品的类别),可供选择</label><br>
				<br><br>
				<label>审核人&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;：</label>
				<input type="text" name="zcperson" id="zcperson" onblur="check6()">
				<div class="dd" id="p6"></div>
				<label>例如&nbsp;：张三</label>
				<br><br>
				<label>购置日期&nbsp;：</label>
				  <div class="layui-inline">
					  <div class="layui-input-inline">
						  <input type="text" name="begint" id="begint" lay-verify="date"  autocomplete="off" class="layui-input">
					  </div>
				  </div>
				  <div>
				<label>例如&nbsp;：2021-08-31(xxxx-xx-xx)</label>
				<br><br>
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

			  </div>

				<input type="submit" id="submit" onclick="submitp()">
			  </div>
        </div>
    </div>
</div>
<!--搜索-->
<div id="search">
	<button type="button" class="close">×</button>
	<form>
		<input type="search" value="" placeholder="type keyword(s) here" />
		<button type="submit" class="btn btn-primary">Search</button>
	</form>
</div>
</body>
<script src="../frame/assets/js/lib/jquery.nanoscroller.min.js"></script>
<script src="../frame/assets/js/lib/menubar/sidebar.js"></script>
<script src="../frame/assets/js/lib/bootstrap.min.js"></script>
<script src="../frame/assets/js/lib/data-table2/datatables.min.js"></script>
<script src="../frame/assets/js/lib/data-table2/dataTables.buttons.min.js"></script>
<script src="../frame/assets/js/lib/data-table2/buttons.flash.min.js"></script>
<script src="../frame/assets/js/lib/data-table2/jszip.min.js"></script>
<script src="../frame/assets/js/lib/data-table2/pdfmake.min.js"></script>
<script src="../frame/assets/js/lib/data-table2/vfs_fonts.js"></script>
<script src="../frame/assets/js/lib/data-table2/buttons.html5.min.js"></script>
<script src="../frame/assets/js/lib/data-table2/buttons.print.min.js"></script>
<script src="../frame/assets/js/lib/data-table2/datatables-init2.js"></script>
<script src="../frame/assets/js/lib/sweetalert/sweetalert.min.js"></script>
<script src="../frame/assets/js/lib/sweetalert/zhuxiao.js"></script>
<script src="../frame/layui/layui.js" charset="utf-8"></script>
<script>
	function checkp1()
	{
		var user=document.getElementById("id");
		var userid=document.getElementById("p1");

		if(user.value=="")
		{
			userid.innerHTML="资产ID不能为空";
			return false;
		}
		if(user.value.length<1 || user.length>10)
		{
			userid.innerHTML="资产ID长度为在2—10字符";
			return false;

		}

		return true;
	}

	function check2(){
		//编码
		var user=document.getElementById("zcid");
		var userid=document.getElementById("p2");
		if(user.value==""){
			userid.innerHTML="编码不能为空";
			return false;
		}
		if(user.value.length<3 || user.value.length>10){
			userid.innerHTML="编码名长度为在4—10字符";
			return false;

		}
		for(var i=0;i<user.value.length;i++){
			var char=user.value.toLowerCase().charAt(i);
			if((i==0&&(char!='z'))||(i==1&&(char!='c'))){
				userid.innerHTML="编码名必须由字母、数字组成";
				return false;
			}
			else if(i>1){
				if(!(char>=0 && char<=9)){
					userid.innerHTML="编码名必须由字母、数字组成";
					return false;
				}
			}
		}
		return true;
	}
	//名称
	function check3()
	{
		var user=document.getElementById("zcname");
		var userid=document.getElementById("p3");
		if(user.value==""){
			userid.innerHTML="名称不能为空";
			return false;
		}
		return true;
	}
	//金额
	function check4(){
		var user=document.getElementById("money");
		var userid=document.getElementById("p4");
		userid.innerHTML="";
		if(user.value==""){
			userid.innerHTML="金额不能为空";
			return false;
		}
		return true;
	}
	//大类

	//审核人
	function check6(){
		var user=document.getElementById("zcperson");
		var userid=document.getElementById("p6");
		userid.innerHTML="";
		if(user.value==""){
			userid.innerHTML="审核人不能为空";
			return false;
		}
		return true;
	}
	//日期
	function check7(){
		var user=begint;
		var userid=$("p7");
		userid.innerHTML="";
		if(user.value==""){
			userid.innerHTML="日期不能为空";
			return false;
		}
		if(user.value.length<1 || user.value.length>10){
			userid.innerHTML="编码名长度为在4—10字符";
			return false;

		}
		for(var i=0;i<user.value.length;i++){
			var char=user.value.toLowerCase().charAt(i);
			if((i==4&&(char!='-'))||(i==7&&(char!='-'))){
				userid.innerHTML="日期格式错误";
				return false;
			}
		}
		return true;
	}




	function submitp(){

		var id=$("#id").val();
		var zcid=$("#zcid").val();
		var zcname=$("#zcname").val();
		var money=$("#money").val();
		var zcclass=$("#zcclass").val();
		var zcperson=$("#zcperson").val();
		var begint=$("#begint").val();
		$.ajax({
			type:'get',
			url:"/addproduct" ,
			contentType:'application/json;charset=utf-8',
			dataType:'html',
			data:{
				'id':id,
				'zcid':zcid,
				'zcname':zcname,
				'money':money,
				'zcclass':zcclass,
				'zcperson':zcperson,
				'begint':begint
			},
			success:function(res){
				layer.msg("添加成功!");
				alert("成功");
			},
			error:function(res){
				layer.msg("添加失败！");
				alert("失败");
			}
		})

	}

	layui.use(['laydate'], function(){
		var laydate = layui.laydate;
		laydate.render({
			elem: '#begint'
		});

	});
</script>
</html>
